<template>
  <h1>表单组件</h1>
  <el-form style="width: 500px; margin: 0 auto;" label-width="80">
    <el-form-item label="用户名">
      <el-input placeholder="请输入您的昵称" v-model="data.username"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input placeholder="请输入您的密码" v-model="data.password"></el-input>
    </el-form-item>
    <el-form-item label="手机号">
      <el-input placeholder="请输入您的手机号" v-model="data.phone"></el-input>
    </el-form-item>
    <el-form-item label="所在地" >
      <el-select placeholder="请选择你喜欢的城市" v-model="data.location">
        <el-option label="广州" value="gz"></el-option>
        <el-option label="深圳" value="sz"></el-option>
        <el-option label="杭州" value="hz"></el-option>
        <el-option label="上海" value="sh"></el-option>
        <el-option label="天津" value="tj"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="管理员">
      <el-switch v-model="data.isAdmin"></el-switch>
    </el-form-item>
    <el-form-item>
      <el-button type="success" @click="f">点我提交</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import {ref} from "vue";
import {ElMessage} from "element-plus";

const data=ref({
  username:"",
  password:"",
  phone:"",
  location:"",
  isAdmin:false
})
const f=()=>{
  ElMessage.success("恭喜你，添加成功")
  console.log(data.value);
  console.log(data.value.username);
}
</script>


<style scoped>

</style>